#!/bin/sh

##################################################
# TiVoGoBack Enabler by Tyler Loch, Techspansion LLC
# http://www.techspansion.com
# Based on the technical ramblings of Dennis Wilkinson
# http://www.tivocommunity.com/tivo-vb/showthread.php?t=298090
##################################################

## Tell the peoples what's happening.
answer=`osascript -l AppleScript -e 'tell application "SystemUIServer" to get button returned of (display dialog "This app will enable TiVoGoBack in TiVoDesktop, then restart your TiVoDesktop Server." buttons {"Run Away", "Continue"} default button "Continue")'`
if [ "$answer"  == "Continue" ]
		then
	## Write them defaults
        defaults write com.tivo.desktop FileVideo -dict-add VideoUIEnabled -bool true
	## Set UID Root? You TiVo guys are crazy. Thanks for making my job easier.
        /Library/Application\ Support/TiVo/StopTiVoDesktop
        /Library/Application\ Support/TiVo/TiVoDesktop
        open /Library/PreferencePanes/TiVoDesktop.prefPane
 	## WHOOSAGOODUSER? Yes you are! YESSYOUARRRE.
	osascript -l AppleScript -e 'tell application "SystemUIServer" to display dialog "Done!" buttons {"Guilt", "Pride"} default button "Pride"'
        exit 0
        fi
if [ "$answer"  == "Run Away" ]
		then
        exit 0
    	fi
   exit 0